package com.lelefly.base.daoimp;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

import com.lelefly.base.model.PlaneDetailBean;
import com.lelefly.base.po.LeleflyUser;
import com.lelefly.db.dbmanager.HibernateSessionFactory;

@Repository
public class UavInfoDao extends BaseDao{

	
	public List<PlaneDetailBean> queryPlaneDetail(String sql){
		
		SessionFactory sessionFactory = HibernateSessionFactory
				.getSessionFactory();
		Session session = sessionFactory.openSession();
		try {
			Query query = session.createSQLQuery(sql).addScalar("totalFlyTime")
			.addScalar("totalFlyArea")
			.setResultTransformer(Transformers.aliasToBean(PlaneDetailBean.class));
			return query.list();
		} catch (Exception e) {
			// TODO: handle exception
			getLogger().info("----->>>" + e.getMessage());
			throw e;
		} finally {
			session.close();
		}
	}
}
